function truncate(title,length){
    var count = 0;
    var output = '';
    for (var i in title){
        output += title.charAt(i);
        var code = title.charCodeAt(i);
        if (code<=50){
            count += 0.5;
        }
        else{
            count ++;
        }
        if (count>length){
            break
        }
    }
    return output + '...';
};



$(document).ready(function(){
    $.ajax({
        url : "/side",
        method : "GET",
        success : function(data) {
            var newData = data[0];
            var mostData = data[1];
            var recData = data[2];

            var v = new Vue({
                el: '#new',
                data: {'content':newData},
                delimiters: ['${','}'],
            });
            var v2 = new Vue({
                el: '#most',
                data: {'content2':mostData},
                delimiters: ['${','}'],
            });
            var v3 = new Vue({
                el: '#recommend',
                data: {'content3':recData},
                delimiters: ['${','}'],
            });

        }
    });

})

$('#loginButton').click(function() {
        window.location.href = '/user/login';
});

$('#regButton').click(function() {
        window.location.href = '/user/register';
});

$('#user-site').click(function() {
    window.location.href = '/user/site';
})

$('#sub-article').click(function() {
    window.location.href = '/public';
})





